package com.zzedu.controller;

import com.zzedu.common.annotation.Log;
import com.zzedu.common.core.controller.BaseController;
import com.zzedu.common.core.domain.AjaxResult;
import com.zzedu.common.core.page.TableDataInfo;
import com.zzedu.common.enums.BusinessType;
import com.zzedu.common.utils.ServletUtils;
import com.zzedu.common.utils.poi.ExcelUtil;
import com.zzedu.domain.ZzAppDeviceLogin;
import com.zzedu.dto.ZzAppDeviceLoginDTO;
import com.zzedu.service.IZzAppDeviceLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * (教育-学校)设备登录信息Controller
 * 
 * @author Mr.Wang
 * @date 2025-06-02
 */
@RestController
@RequestMapping("/school/devicelogin")
public class ZzAppDeviceLoginController extends BaseController
{
    @Autowired
    private IZzAppDeviceLoginService zzAppDeviceLoginService;

    /**
     * 查询(教育-学校)设备登录信息列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:devicelogin:query')")
    @RequestMapping("/list")
    public TableDataInfo list(@RequestBody ZzAppDeviceLoginDTO zzAppDeviceLogin)
    {
        return getDataTable(zzAppDeviceLoginService.page(zzAppDeviceLogin.getPageDTO(),zzAppDeviceLoginService.buildQuery(zzAppDeviceLogin)));
    }

    /**
     * 导出(教育-学校)设备登录信息列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:devicelogin:export')")
    @Log(title = "(教育-学校)设备登录信息", businessType = BusinessType.EXPORT)
    @RequestMapping("/export")
    public void export(ZzAppDeviceLoginDTO zzAppDeviceLogin)
    {
        List<ZzAppDeviceLogin> list = zzAppDeviceLoginService.list(zzAppDeviceLoginService.buildQuery(zzAppDeviceLogin));
        ExcelUtil<ZzAppDeviceLogin> util = new ExcelUtil<ZzAppDeviceLogin>(ZzAppDeviceLogin.class);
        util.exportExcel(ServletUtils.getResponse(),list, "(教育-学校)设备登录信息数据");
    }




    /**
     * 新增保存(教育-学校)设备登录信息
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:devicelogin:add')")
    @Log(title = "(教育-学校)设备登录信息", businessType = BusinessType.INSERT)
    @RequestMapping("/add")
    public AjaxResult addSave(@Validated @RequestBody ZzAppDeviceLogin zzAppDeviceLogin)
    {
        return toAjax(zzAppDeviceLoginService.save(zzAppDeviceLogin));
    }



    /**
     * 获取(教育-学校)设备登录信息详细信息
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:devicelogin:query')")
    @RequestMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zzAppDeviceLoginService.getById(id));
    }


    /**
     * 修改保存(教育-学校)设备登录信息
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:devicelogin:edit')")
    @Log(title = "(教育-学校)设备登录信息", businessType = BusinessType.UPDATE)
    @RequestMapping("/edit")
    public AjaxResult editSave(@Validated @RequestBody ZzAppDeviceLogin zzAppDeviceLogin)
    {
        return toAjax(zzAppDeviceLoginService.updateById(zzAppDeviceLogin));
    }

    /**
     * 删除(教育-学校)设备登录信息
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:devicelogin:remove')")
    @Log(title = "(教育-学校)设备登录信息", businessType = BusinessType.DELETE)
	@RequestMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(zzAppDeviceLoginService.removeBatchByIds(ids));
    }
}
